package com.vivien.example.springbootdemo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.vivien.example.springbootdemo.pojo.Employee;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmployeeMapper extends BaseMapper<Employee> {

    @Select("select id,last_name,age from tbl_employee where age=#{age}")
    List<Employee> selByCustom(Integer age);

    @Select("<script>" +
            "select * from tbl_employee where 1=1"+
            "<if test='name!=null and name!=\"\"'>"+
                " and name like '%${name}%'"+
            "</if>"+
            "</script>")
    List<Employee> getEmpByCon(@Param("name") String name,
                               @Param("age") Integer age,
                               @Param("sort") String sort);

}
